package com.example.pattern.iterator;

import java.util.List;

/**
 * 具体迭代器实现
 *
 * @author FM_南风
 * @date 2024/7/6
 */
public class ConcreteIterator<T> implements IteratorPatternIterator<T> {
	private List<T> elements;
	private int position;

	public ConcreteIterator(List<T> elements) {
		this.elements = elements;
		this.position = 0;
	}

	@Override
	public boolean hasNext() {
		return position < elements.size();
	}

	@Override
	public T next() {
		return elements.get(position++);
	}
}